#include "stdafx.h"
#include "BigNum.h"

using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;

namespace BigNumUnitTest
{
	[TestClass]
	public ref class UnitTest
	{
	private:
		TestContext^ testContextInstance;

	public: 
		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		property Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ TestContext
		{
			Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ get()
			{
				return testContextInstance;
			}
			System::Void set(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ value)
			{
				testContextInstance = value;
			}
		};

		#pragma region Additional test attributes
		//
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//static void MyClassInitialize(TestContext^ testContext) {};
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//static void MyClassCleanup() {};
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//void MyTestInitialize() {};
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//void MyTestCleanup() {};
		//
		#pragma endregion 

		[ClassInitialize]
		static void Initialize(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ testContext) 
		{
			bn1 = new BigNum("1111111111111111111111111111111111111111111111111");
			bn2 = new BigNum("0000000000000000000000000001111111111111111111111");
			result = new BigNum();
		};

		[ClassCleanup]
		static void Cleanup() 
		{
			delete bn1;
			delete bn2;
			delete result;
		};

#pragma region BigNum::Add Unit Tests

		[TestMethod]
		void TestAddMethod1_Seq()
		{
			BigNum::Add(*bn1,*bn1,*result);
			Assert::AreEqual<String^>("2222222222222222222222222222222222222222222222222", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

		[TestMethod]
		void TestAddMethod1_Par()
		{
			BigNum::Add(*bn1,*bn1,*result, 4);
			Assert::AreEqual<String^>("2222222222222222222222222222222222222222222222222", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Subtract Unit Tests

		[TestMethod]
		void TestSubtractMethod1_Seq()
		{
			BigNum::Subtract(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1111111111111111111111111110000000000000000000000", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

		[TestMethod]
		void TestSubtractMethod1_Par()
		{
			BigNum::Subtract(*bn1,*bn2, *result, 4);
			Assert::AreEqual<String^>("1111111111111111111111111110000000000000000000000", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Multiply Unit Tests

		[TestMethod]
		void TestMultiplyMethod1()
		{
			BigNum::Multiply(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion
	
#pragma region BigNum::Divide Unit Tests

		[TestMethod]
		void TestDivideMethod1()
		{
			BigNum::Divide(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::LeftShift Unit Tests

		[TestMethod]
		void TestLeftShiftMethod1()
		{
			BigNum::LeftShift(*bn1, 2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::RightShift Unit Tests

		[TestMethod]
		void TestRightShiftMethod1()
		{
			BigNum::RightShift(*bn1, 2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::And Unit Tests

		[TestMethod]
		void TestAndMethod1()
		{
			BigNum::And(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Or Unit Tests

		[TestMethod]
		void TestOrMethod1()
		{
			BigNum::Or(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Xor Unit Tests

		[TestMethod]
		void TestXorMethod1()
		{
			BigNum::Xor(*bn1,*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Not Unit Tests

		[TestMethod]
		void TestNotMethod1()
		{
			BigNum::Not(*bn2, *result);
			Assert::AreEqual<String^>("1", gcnew String((BigNum::GetNumber(*result)).c_str()));
		};

#pragma endregion

#pragma region BigNum::Equal Unit Tests

		[TestMethod]
		void TestEqualMethod1()
		{
			Assert::AreEqual<bool>(true, BigNum::Equal(*bn1,*bn2));
		};

#pragma endregion

	private:
		static const BigNum* bn1;
		static const BigNum* bn2;
		static BigNum* result;
	};
}
